export default{
    ajaxPost(functionNo, data, jsonpname, callback, timeout){
      //var timestamp = (new Date()).valueOf();
      //data += "&timestamp=" + timestamp;
      var network = $.hsf.network();
      if(network == 'succ'){
        var request_temp = $.ajax({
            url:functionNo + '.do',
            type: "POST",
            //dataType: "jsonp",
            //jsonp: "jsonpCallback",
            //jsonpCallback: "hundsun_" +jsonpname+ timestamp,
            data: data,
            timeout: 60000
        }).done(function(res){
            callback && callback.call(this,res);
        }).fail(function(){
              var result = {
                "code": "NETWORK_ERROR",
                "message": "网络异常"
              };
              callback && callback.call(this, result);
        })
        return request_temp;
      }else{
        var result = {
          "code": "NETWORK_ERROR",
          "message": "网络异常"
        };
        callback && callback.call(this, result);
      }
    },
    ajaxGet(url,data,callback){
      var network = $.hsf.network();
      if(network == 'succ'){
        var request_temp = $.ajax({
              type:'get',
              url:url + '.do',
              data:data
          }).done(function(res){
              callback && callback.call(this,res);
          }).fail(function(){
              var result = {
                "code": "NETWORK_ERROR",
                "message": "网络异常"
              };
              callback && callback.call(this, result);
        })
        return request_temp;
      }else{
        var result = {
          "code": "NETWORK_ERROR",
          "message": "网络异常"
        };
        callback && callback.call(this, result);
      }
    }
}